<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-cookie.js"></script>
<script type="text/javascript" src="/js/base64.min.js"></script>
<script type="text/javascript" src="/js/func.js"></script>
<script type="text/javascript" src="/lang/b28n.js"></script>
<link rel="stylesheet" href="/css/dwdoor.css" type="text/css" charset="utf-8">
<link rel="stylesheet" type="text/css" href="/css/index.css">
<style type="text/css" media="screen"></style>
<style type="text/css">
    div.contain div.mt300{
        margin-top: 252px;
    }

    table.body{
        border: 1px solid #c2c2c2;
        border-collapse: collapse;
    }
    table.body, table.body th, table.body td{
        border: 1px solid #c2c2c2;
     /*   border-collapse: collapse;*/
    }
    div.contain div.noborder{
        border: 0px;
    }
    div.btn-part{
        margin-top: 20px;
    }
    div.no-pad-top{
        margin-top: 0px;
        /*padding-top: 0px;*/
    }
    div.left{
        float: left;
       /* margin: 0px;*/
    }
    div.right{
        float: right;
        /*margin: 0px;*/
    }
    div.button-container  button.btn-pre{
        margin-right:10px;
    }
    div.button-container  button.btn-next{
        margin-left:10px;
    }
    input.current{
        width:28px;
        height: 28px;
        text-align: center;
        border: 1px solid #aaa;
        margin: 0px 5px;
        vertical-align: middle;
    }
    div.hidden{
        display: none;
    }
</style>
</head>
<body onLoad="onInit()">
<div class="contain">   

<div class="content">
	<div id="access_staff" class=""> 
	 <div class="sec" style="border:0px;">    

		<table width="100%" border="1" cellpadding="2" cellspacing="1" id="staff_table4" style="padding-left:0px;padding-right:0px">
		<tr>
			<td class="title" colspan="3" id="et0">最近通行记录明细</td>
		</tr>
		<tr align="center">
			<th rowspan="8"><img id="ep0" alt="staff picture"  style="display:block;margin:0px auto;max-width:287px;max-height:134px;"></th>
			<td class="head" style="{width:30%;height:100%;}" id="eh0">姓名</td>
			<td id="e0" style="{width:35%;height:100%;}">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</td>				
		</tr>
		<tr align="center">
			<td class="head" style="{width:30%;height:100%;}" id="eh1">工种</td>
			<td id="e1" style="{width:35%;height:100%;}">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</td>
		</tr>
		<tr align="center">
			<td class="head" style="{width:30%;height:100%;}" id="eh2">卡号</td>
			<td id="e2" style="{width:35%;height:100%;}">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</td>
		</tr>
		<tr align="center">
			<td class="head" style="{width:30%;height:100%;}" id="eh3">控制器</td>
			<td style="{width:35%;height:100%;}" id="e3">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</td>
		</tr>
		</tr>  	
		 <tr align="center">
			<td class="head" style="{width:30%;height:100%;}" id="eh4">闸号</td>
			<td style="{width:35%;height:100%;}" id="e4">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</td>
		</tr>
		 <tr align="center">
			<td class="head" style="{width:30%;height:100%;}" id="eh5">进入时间</td>
			<td style="{width:35%;height:100%;}" id="e5">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</td>
		</tr>
		<tr align="center">
			<td class="head" style="{width:30%;height:100%;}" id="eh6">当天进场人数</td>
			<td style="{width:35%;height:100%;}" id="e6">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</td>
		</tr>
		 <tr align="center">
			<td class="head" style="{width:30%;height:100%;}" id="eh7">当天出场人数</td>
			<td style="{width:35%;height:100%;}" id="e7">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</td>
		</tr>	
		</table>		
		<br />
	 </div>
	</div>
</div>  


<div class="sec  noborder" id="div_date_1">
 <form method="post" id="controler" action="" enctype="">
      <table class="body" width="95%" border="1" cellpadding="2" cellspacing="1" id="staff_table1">
        <tr id="s0" align="center">
		  
           <th class="title" width="10%" id="s00_0">控制器</th>
		   <th class="title" width="18%" id="s00_1">IP</th>
		   <th class="title" width="13%" id="s00_2">PORT</th>
		   <th class="title" width="20%" id="s00_3">最近连接时间</th>
           <th class="title" width="13%" id="s00_4">状态</th>
           <th class="title" width="13%" id="s00_5">删除</th>
           <th class="title" width="13%" id="s00_6">清除数据</th>
        </tr>
    </table>
  </form>	
       <div class="button-container right"  style="padding-top:0px;">
                <button id="pagebnpre0" class="button-button btn-pre" type="button"   value="上一页" onclick='setpagebnpre0();'>上一页 </button>                   
                第<input id="pagebn0" type="text" class="current"  value=""/>页&nbsp;   
                <button id="pagebnnxt0" class="button-button btn-next" type="button"  value="上一页" onclick='setpagebnnxt0();'>下一页 </button>                            
       </div>
</div>

</br>
<div class="sec  noborder" id="div_date_2">
  <form method="post" id="outputExcelall" > 
      <table class="body" width="95%" border="1" cellpadding="2" cellspacing="1" id="staff_table2">
        <tr id="s0" align="center">
		  
           <th class="title" width="10%" id="s0_0">序号</th>
           <th class="title" width="20%" id="s0_1">卡号</th>
           <th class="title" width="12%" id="s0_2">闸号</th>
           <th class="title" width="19%" id="s0_3">设备号</th>
           <th class="title" width="19%" id="s0_4">刷卡时间</th>
		   <th class="title" width="10%" id="s0_5">是否放行</th>
		   <th class="title" width="10%" id="s0_6">是否在内</th>
        </tr>
    </table>
  </form>
            <div class="btn-part no-pad-top">       
                <div class="button-container left" style="padding-top:0px;">                    
                    <button id="mandbImport" class="button-button button-button-auto btn-export-all" download="download.csv" onclick='return outputpreconfirm();'><span class="text button-text">导出全部文件</span></button>
                </div>
                <div class="button-container right"  style="padding-top:0px;">
                <button id="pagebnpre" class="button-button btn-pre" type="button"   value="上一页" onclick='setpagebnpre();'>上一页 </button>                   
                第<input id="pagebn" type="text" class="current"  value=""/>页&nbsp;   
                <button id="pagebnnxt" class="button-button btn-next" type="button"  value="上一页" onclick='setpagebnnxt();'>下一页 </button>                            
                </div>
            </div>

</div>

<div class="sec" id="div_date_3" style="display:none">
<div class="title">设备参数设置</div>
</div>

</div>
</body>
<script type="text/javascript">  
Butterlate.setTextDomain("dwdoor");

var table1 = document.getElementById('staff_table1');
function setTab1()
{ 
    
    var rowslen = table1.rows.length;  	
    for(var j=rowslen-1;j>=1;j--)
	{
	    table1.deleteRow(j);
	}
//    alert("rowslen:"+rowslen);	
	$.ajax({
        url: "/dwgetcontroler.php",
        type: "POST",
        timeout: 180000,
        data: "",
        dataType: "text",
//			async: true,
        error: function()
		{
		    $('#massage_text').text('网络错误。'); 
            return false;
        },
        complete: function()
		{              
            if (status === 'timeout')
			{
                $('#massage_text').text('超时。');
				this.abort();
            }
        },
        success: function(deReturn)
		{
//            console.log(deReturn);
//			alert(deReturn);
//	    	var deRe;
            var controlertab = jQuery.parseJSON(deReturn);
           	var nrows= parseInt(controlertab.nrows);
	        var ncols= parseInt(controlertab.ncols);
            table1.pageMaxium=parseInt(controlertab.pageMaxium);
//		alert("pagemax:"+pagemax);
	        var controlerpagenum=controlertab.controlerpagenum;
            pageMaxium=parseInt(controlerpagenum);
//		
//            console.log(nrows);
            if(nrows > 5)
            {
                nrows = 5;
            }
	        for(var l=1;l<=nrows;l++)
	        {		    
                inrow=table1.insertRow(l);			
	            inrow.setAttribute("id","s0" + l);
		        inrow.setAttribute("align","center");
                
				for(var m=0;m<ncols;m++)
                {
		            var incell = inrow.insertCell(m);
					if(m==0)
					{
					    incell.innerHTML = '<td><class="head2" id="s0'+l+'_'+m+'"><a href="http://'+controlertab['s0'+l+'_1']+':'+controlertab['s0'+l+'_2']+'" target="_blank"> '+controlertab['s0'+l+'_'+m]+'<\a></td>';
					}else
					{
			            incell.innerHTML = '<td><class="head2" id="s0'+l+'_'+m+'">'+controlertab['s0'+l+'_'+m]+'</td>';			    		
		            }
				}
				incell = inrow.insertCell(ncols);
				incell.innerHTML = '<td><button class="head2" id="s0'+l+'_'+ parseInt(ncols) +'" type="button" value="delete" onclick="setDelete(\''+ controlertab['s0'+l+'_0'] +'\');"></button></td>';
//	            alert("ncols:"+(ncols+1));
				incell = inrow.insertCell(parseInt(ncols)+1);
				incell.innerHTML = '<td><button class="head2" id="s0'+l+'_'+(parseInt(ncols)+1)+'" type="button" value="erase" onclick="setErase(\''+ controlertab['s0'+l+'_0'] +'\');"></button></td>';
//			    alert(incell.innerHTML);
			}
	        var bn=document.getElementById("pagebn0");
	//bn.value="第"+pagei+"页"; 
            table1.pageIndex = controlertab.controlerpagenum;
            if(isNaN(table1.pageIndex))	
            {
                table1.pageIndex = 0;
            }
            bn.value=table1.pageIndex;		
        }
    });	     
}

function fn1(controlertab, l)
{
   return  '<a href="http://'+controlertab['s0'+l+'_1']+':'+controlertab['s0'+l+'_2']+'" target="_blank">link<\a>';
}

function fn2(controlertab, l, ncols)
{
   return  '<button class="head2" id="s0'+l+'_'+(parseInt(ncols)+1)+'" type="button" value="erase" onclick="setErase('+ controlertab['s0'+l+'_0'] +');"></button>';
}

function setpagebnpre0()
{
    if(table1.pageIndex==1)
	{
        alert("当前已经是第一页!");
	}else
	{
	    var temppageIndex = parseInt(table1.pageIndex) - 1;
//        ajaxLoadDataGrid("staff_table1","/dwgetcontroler.php",{"page":temppageIndex},"pagebn0",temppageIndex,7,[null,null,null,null,null,fn1,fn2]);
		ajaxLoadDataGrid("staff_table1","/dwgetcontroler.php",{"page":temppageIndex},"pagebn0",temppageIndex,5,[null,null,null,null,null,fn1,fn2]);
	}
}

function setpagebnnxt0()
{
    if(table1.pageIndex==table1.pageMaxium)
	{
		alert("当前已经是最后一页!");
	}else
	{
	    //pageIndex += 1;
        var temppageIndex = parseInt(table1.pageIndex) + 1;
//        ajaxLoadDataGrid("staff_table1","/dwgetcontroler.php",{"page":temppageIndex},"pagebn0",temppageIndex,7,[null,null,null,null,null,fn1,fn2]);
		ajaxLoadDataGrid("staff_table1","/dwgetcontroler.php",{"page":temppageIndex},"pagebn0",temppageIndex,5,[null,null,null,null,null,fn1,fn2]);
	}
}

$("#pagebn0").bind("keypress", function(event){
    // console.log(event);
    if(event.keyCode == "13")
    {
        var num =  parseInt($("#pagebn0").val());
        if(isNaN(num))
        {
            alert("非法的页数");
        }
        if((num <= 0) || (num > table1.pageMaxium))
        {
            alert("非法的页数");
        }
//		alert("num:"+num);
		var temppageIndex = num;
//        ajaxLoadDataGrid("staff_table1","/dwgetcontroler.php",{"page":temppageIndex},"pagebn0",temppageIndex,7,[null,null,null,null,null,fn1,fn2]);
		ajaxLoadDataGrid("staff_table1","/dwgetcontroler.php",{"page":temppageIndex},"pagebn0",temppageIndex,5,[null,null,null,null,null,fn1,fn2]);
	}
})

//tab2 setup
//var pagei=1;
//var pagemax=1;

var table2 = document.getElementById('staff_table2');
function setTab2()
{
    
    var rowslen = table2.rows.length;   
    for(var j=rowslen-1;j>=1;j--)
    {
        table2.deleteRow(j);
    }
//    alert("rowslen:"+rowslen);    
    $.ajax({
        url: "/dwaccessrecord.php",
        type: "POST",
        timeout: 180000,
        data: "",
        dataType: "text",
//          async: true,
        error: function()
        {
            $('#massage_text').text('网络错误。'); 
            return false;
        },
        complete: function()
        {              
            if (status === 'timeout')
            {
                $('#massage_text').text('超时。');
                this.abort();
            }
        },
        success: function(deReturn)
        {
//            console.log(deReturn);
//          alert(deReturn);
//          var deRe;
            var controlertab = jQuery.parseJSON(deReturn);
            var nrows=controlertab.nrows;
            var ncols=controlertab.ncols;
            table2.pageMaxium=controlertab.pageMaxium;
//			pagemax=controlertab.pageMaxium;
//      alert("pagemax:"+pagemax);
            var controlerpagenum=controlertab.controlerpagenum;
//            pagemax=parseInt(table2.pageMaxium);
//            console.log(nrows);
            if(nrows > 10)
            {
                nrows = 10;
            }
            for(var l=1;l<=nrows;l++)
            {           
                inrow=table2.insertRow(l);          
                inrow.setAttribute("id","s" + l);
                inrow.setAttribute("align","center");
                for(var m=0;m<ncols;m++)
                {
                    var incell = inrow.insertCell(m);
					if(m==0)
					{
						incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'"><a href="/pictureshow.php?picfilename='+controlertab['s0'+l+'_'+m]+'.jpg">'+controlertab['s0'+l+'_'+m]+'<\a></td>';
					}else if(m==2)
				    {
					    if(controlertab['s0'+l+'_'+m]=='0') incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'一号进口'+'</td>';
					    if(controlertab['s0'+l+'_'+m]=='1') incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'一号出口'+'</td>';
					    if(controlertab['s0'+l+'_'+m]=='2') incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'二号进口'+'</td>';
					    if(controlertab['s0'+l+'_'+m]=='3') incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'二号出口'+'</td>';
			        }else if(m==5)
				    {
					    if(controlertab['s0'+l+'_'+m]=='pass')
						{
							incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'是'+'</td>';
					    }else
						{
							incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'否'+'</td>';
						}
			        }else if(m==6)
				    {
					    if(controlertab['s0'+l+'_'+m]=='in')
						{
							incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'是'+'</td>';
					    }else
						{
							incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'否'+'</td>';
						}
			        }					
					else
                    {            
        				incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+controlertab['s0'+l+'_'+m]+'</td>';
				    }
                }
            }
            var bn=document.getElementById("pagebn"); 
            table2.pageIndex = parseInt(controlertab.controlerpagenum);
            if(isNaN(table2.pageIndex))    
            {
                table2.pageIndex = 0;
            }
            bn.value=table2.pageIndex;     
        }
    });      
}

function setpagebnpre()
{
    if(table2.pageIndex==1)
    {
        alert("当前已经是第一页!");
    }else
    {
        var temppageIndex = parseInt(table2.pageIndex) - 1;
//        ajaxLoadDataGrid("staff_table2","/dwaccessrecord.php",{"page":temppageIndex},"pagebn",temppageIndex,5,[null]);
		ajaxLoadDataGrid("staff_table2","/dwaccessrecord.php",{"page":temppageIndex},"pagebn",temppageIndex,7,[null]);
    }
}

function setpagebnnxt()
{
    if(table2.pageIndex==table2.pageMaxium)
    {
        alert("当前已经是最后一页!");
    }else
    {
        //pageIndex += 1;
        var temppageIndex = parseInt(table2.pageIndex) + 1;
//		alert("...temppageIndex:  "+temppageIndex);
//        ajaxLoadDataGrid("staff_table2","/dwaccessrecord.php",{"page":temppageIndex},"pagebn",temppageIndex,5,[null]);
		 ajaxLoadDataGrid("staff_table2","/dwaccessrecord.php",{"page":temppageIndex},"pagebn",temppageIndex,7,[null]);
    }
}


function outputpreconfirm()
{
    var r = confirm("温馨提示：导出的文件中含有中文时，请用新的EXCEL表选择：数据->来自文本->带逗号的格式 导入打开。");    
	if (r==true)
    {
        document.getElementById("outputExcelall").action="/dwDownExcel.php?table=accessrecord";
    	downloadExcel("accessrecord","outputExcelall");
    }
  	else
    {
    	return false;
    }
}

function viewaccessdetailTab()
{
	$.ajax({
		url: "/dwviewaccessdetail.php",
		type: "POST",
		timeout: 180000,
		data: {"action":"view"},
		dataType: "text",
		//      async: true,
//		console.log("data");
		error: function()
		{
			$('#massage_text').text('网络错误。'); 
			return false;
		},
		complete: function()
		{              
			if (status === 'timeout')
			{
				$('#massage_text').text('超时。');
				this.abort();
			}
		},
		success: function(deReturn)
		{
//			console.log(deReturn);
			var item = jQuery.parseJSON(Base64.decode(deReturn));
//			console.dir(item);
			if(!item.staffname) item.staffname="无";
			if(!item.departmentname) item.departmentname="无";
			$("#e0").html(item.staffname);
			$("#e1").html(item.departmentname);
			$("#e2").html(item.cardnum);
			$("#e3").html(item.controlerNum);
			$("#e4").html(item.gatenum);
			$("#e5").html(item.CreatedTime);
			$("#e6").html(item.todayin);
			$("#e7").html(item.todayout);
//			console.log(item.picfilename);
//			$("#ep0").html(item.picfilename);
			var picfilename = "/pictures/"+item.picfilename+".jpg";
//			console.log(picfilename);
			$("#ep0").attr("src",picfilename);	
			
			var showDiv = document.getElementById("access_staff"); 
			showDiv.style.display = "block"; 
		}
	});
}

function initTranslation()
{
	var e = document.getElementById("Gate Config");
	e.innerHTML = _("Gate Config");
	e = document.getElementById("GateIntroduction");
	e.innerHTML = _("GateIntroduction");
}

$("#pagebn").bind("keypress", function(event){
    // console.log(event);
    if(event.keyCode == "13")
    {
        var num =  parseInt($("#pagebn").val());
        if(isNaN(num))
        {
            alert("非法的页数");
        }
        if((num <= 0) || (num > table2.pageMaxium))
        {
            alert("非法的页数");
        }
//		alert("num:"+num);
        // console.log(num);
//        makeRequest("/goform/dwsetaccesspage",num.toString());     
//        window.location.reload();
		var temppageIndex = num;
        ajaxLoadDataGrid("staff_table2","/dwaccessrecord.php",{"page":temppageIndex},"pagebn",temppageIndex,5,[null]);
    }
})

function SetIntel()
{
    setTab1();
    setTab2();
	viewaccessdetailTab();
	window.setInterval(function(){
        setTab1();
		setTab2();       
    }, 60000);
	window.setInterval(function(){  
		probeDevice();
    }, 6000);
}

function probeDevice()
{
	$.ajax({
        url: "/_probeDevice.php",
        type: "POST",
        timeout: 180000,
        data: "",
        dataType: "text",
//			async: true,
        error: function()
		{
		    $('#massage_text').text('网络错误。'); 
            return false;
        },
        complete: function()
		{              
            if (status === 'timeout')
			{
                $('#massage_text').text('超时。');
				this.abort();
            }
        },
        success: function(deReturn)
		{
//            console.log(deReturn);
	    	if(deReturn) var deRe = jQuery.parseJSON(Base64.decode(deReturn));
//			console.dir(Base64.decode(deReturn));
            if(deRe.res === "success")
		    {
//			    console.dir(deRe);
//              console.log("success");
//                $('#massage_text').text('success。'); 				
            }else
		    {
//		        $('#massage_text').text('用户名错，请重新输入。'); 
                return false;
            }			
        }
    });	
}

function setDelete(controlerNum)
{
	var deData = "{\"controlerNum\":\""+ controlerNum +"\",\"cmd_mode\":\"KQ_DELETE\"}";
//	alert("deData:"+deData);
//	var deSend="de="+base64encode(deData);
	var deSend="de="+deData;
	$.ajax({
        url: "/deleteDevice.php",
        type: "POST",
        timeout: 180000,
        data: deSend,
        dataType: "text",
//			async: true,
        error: function()
		{
		    $('#massage_text').text('网络错误。'); 
            return false;
        },
        complete: function()
		{              
            if (status === 'timeout')
			{
                $('#massage_text').text('超时。');
				this.abort();
            }
        },
        success: function(deReturn)
		{
            console.log(deReturn);
            if(deReturn) var deRe = jQuery.parseJSON(Base64.decode(deReturn));				
            if(deRe.res === "success")
		    {
//			    console.log(deRe);
//              console.log("success");
//                $('#massage_text').text('success。');  				
				alert(controlerNum+" 设备删除成功。");
				setTab1();
            }else if(deRe.res === "error")
		    {
//		        $('#massage_text').text('用户名错，请重新输入。'); 
                return false;
            }			
        }
    });	
}

function setErase(controlerNum)
{
//    alert("controlerNum:"+controlerNum);
	var deData = "{\"controlerNum\":\""+ controlerNum +"\",\"cmd_mode\":\"KQ_INIT\"}";
//	alert("deData:"+deData);
//	var deSend="de="+base64encode(deData);
	var deSend="de="+deData;
	$.ajax({
        url: "/eraseDevice.php",
        type: "POST",
        timeout: 180000,
        data: deSend,
        dataType: "text",
//			async: true,
        error: function()
		{
		    $('#massage_text').text('网络错误。'); 
            return false;
        },
        complete: function()
		{              
            if (status === 'timeout')
			{
                $('#massage_text').text('超时。');
				this.abort();
            }
        },
        success: function(deReturn)
		{
//            console.log(deReturn);
            if(deReturn) var deRe = jQuery.parseJSON(Base64.decode(deReturn));
			console.log(deRe);	
            if(deRe.res === "success")
		    {
//			    console.log(deRe);
//              console.log("success");
//                $('#massage_text').text('success。');  
				alert(controlerNum+" 设备数据清除成功。");
            }else if(deRe.res === "error")
		    {
//		        $('#massage_text').text('用户名错，请重新输入。'); 
                return false;
            }			
        }
    });	
}

function onInit()
{    
    SetIntel();       
}
function setdiv(controlerNum)
{
//    console.log(controlerNum);
	document.getElementById("div_date_1").style.display="none";
	document.getElementById("div_date_2").style.display="none";
	document.getElementById("div_date_3").style.display="block";
}
function dwGatesubmit()
{
    if(dwGateSettingCheck()) document.getElementById("dwGateSetting").submit();
}

$(function(){
		if($.cookie('logon') === "null" || !$.cookie('logon')){
		    top.window.location.pathname = '/login.php';
		}
		
  	function checkCookie(){
	  	var a = $.cookie('logon') === "null" || !$.cookie('logon');
	  	if(a){
	  		top.window.location.pathname = '/login.php';
	  	}else{
		    var date = new Date();
		    date.setTime(date.getTime() + (60 * 60 * 1000));
		    $.cookie('logon',true,{expires: date});		 
		}
	  }
	});
</script>
</html>
